import selenium
import selenium.webdriver  # 模拟浏览器
import re


def getnumberbyname(searchname):
    url = "https://search.51job.com/list/072000,000000,0000,00,9,99,"+searchname + \
        ",2,1.html?lang=c&stype=&postchannel=0000&workyear=99&cotype=99&degreefrom=99&jobterm=99&companysize=99&providesalary=99&lonlat=0%2C0&radius=-1&ord_field=0&confirmdate=9&fromType=&dibiaoid=0&address=&line=&specialarea=00&from=&welfare="
    driver = selenium.webdriver.Firefox()

    driver.get(url)
    pagesource = driver.page_source  # 抓取网页源代码
    # print(pagesource)    
    restr = """<div class="rt">([\\s\\S]*?)</div>"""
    regex = re.compile(restr, re.IGNORECASE)
    mylist = regex.findall(pagesource)
    driver.close()  # 关闭
    return mylist

print(getnumberbyname("python"))
